/*
 * @Descripttion: your project
 * @version: 1.0
 * @Author: hongweixun
 * @Date: 2023-05-17 13:58:40
 * @LastEditors: liyin 2179253556@qq.com
 * @LastEditTime: 2025-08-29 15:37:45
 */

import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from 'vue-router'
const routes: Array<RouteRecordRaw> = [
    { path: '/', redirect: '/HomeView' },
    {
      path: '/HomeView',
      name: 'HomeView',
      meta: {
        title: '首页',
        keetAlive: false
      },
      component: () => import('../components/HomeView.vue')
    },
    // {
    //   path: "/:catchAll(.*)", // 不识别的path自动匹配404
    //   redirect: '/404',
    // },
]
const routerHistory = createWebHistory('./')
const router = createRouter({
  // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
  history: import.meta.env.MODE === 'development' ? createWebHashHistory() : createWebHashHistory(),
  routes, // `routes: routes` 的缩写
  // 滚动行为，切换页面就置顶
  scrollBehavior(to:any, from:any, savedPosition:any) {
    console.log(to)
    console.log(from)
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  }
})
export default router